package org.budo.dubbo.protocol.http.exception.remoting;

import com.alibaba.dubbo.common.utils.StringUtils;

import lombok.Getter;
import lombok.Setter;

/**
 * @author lmw
 */
@Getter
@Setter
public class ArgumentTimeFormatException extends RemotingRuntimeException {
    private static final long serialVersionUID = 216453244435452765L;

    private Integer parameterIndex;

    private Class<?> parameterType;

    private String parameterName;

    private Object argumentValue;

    private String[] timeFormats;

    public ArgumentTimeFormatException() {}

    public ArgumentTimeFormatException(Integer parameterIndex, Class<?> parameterType, String parameterName, Object argumentValue, String[] timeFormats) {
        this.parameterIndex = parameterIndex;
        this.parameterType = parameterType;
        this.parameterName = parameterName;
        this.argumentValue = argumentValue;
        this.timeFormats = timeFormats;
    }

    public String getMessage() {
        return "time argument miss match the timeFormats[" + StringUtils.join(this.getTimeFormats()) + "]" //
                + ", parameterIndex is " + this.getParameterIndex() //
                + ", parameterName=" + this.getParameterName() //
                + ", parameterType=" + this.getParameterType() //
                + ", argumentValue=" + this.getArgumentValue();
    }
}